package com.keithpower.freshdox;

import java.util.Enumeration;

import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;

public class Test
{
    private String language = "Java(BeanShell)"; // default

    private String conditionCode = "";

    private String code = "";

    private String name;

    private String dependencies = "";

    private String errorInfo = "";

    private Hashtable configuration;

    public Test()
    {
	this.configuration = new Hashtable();
    }

    public String getLanguage()
    {
	return this.language;
    }

    public String getError()
    {
	return this.errorInfo;
    }

    public String getName()
    {
	return this.name;
    }

    public String getDependencies()
    {
	return this.dependencies;
    }

    public String getCode()
    {
	return this.code;
    }

    public String getConditionCode()
    {
	return this.conditionCode;
    }

    public void setName(String testName)
    {
	this.name = testName;
    }

    public void setCode(String codeStr)
    {
	this.code = codeStr;
    }

    public void setConditionCode(String codeStr)
    {
	this.conditionCode = codeStr;
    }

    // TODO NOTE this needs to take name and value
    public void addConfig(String prop, String configStr)
    {
	this.configuration.put(prop, configStr);
    }

    public void setLanguage(String testLang)
    {
	this.language = testLang;
    }

    public void setErrorInfo(String reason)
    {
	this.errorInfo = reason;
    }

    public String toString()
    {
	String desc = "Name: " + this.name + "\n";
	desc += "Language: " + this.language + "\n";
	desc += "Configuration: \n";

	Enumeration configKeys = this.configuration.keys();
	while (configKeys.hasMoreElements())
	{
	    String configName = (String) configKeys.nextElement();
	    desc += configName + " = " + this.configuration.get(configName)
		    + "\n";
	}

	desc += "Code: " + this.code + "\n";
	desc += "Condition: " + this.conditionCode + "\n";
	return desc;
    }
}
